<?php

use Drupal\gateway_client\GatewayClient;

function gateway_client_debug_form($form, &$form_state) {
  $form['uid'] = [
    '#title' => t('接收者 UID'),
    '#type' => 'textfield',
    '#required' => TRUE,
  ];
  $form['key'] = [
    '#title' => t('数据 KEY'),
    '#type' => 'textfield',
    '#required' => TRUE,
  ];

  $form['data'] = [
    '#title' => t('数据'),
    '#type' => 'textarea',
    '#description' => t('json 格式'),
  ];

  $form['actions'] = ['#type' => 'actions'];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => t('提交'),
  ];

  return $form;
}

function gateway_client_debug_form_submit($form, &$form_state) {
  $client = new GatewayClient();
  $uid = $form_state['values']['uid'];
  $key = $form_state['values']['key'];
  $data = $form_state['values']['data'];
  $data = drupal_json_decode($data);
  $client->pushUid($uid, $key, $data);
}